﻿<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
	<title xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory">Chapter 13. EPL Reference: Aggregation Methods</title>
	<link rel="stylesheet" href="css/espertech.css" type="text/css">
	<meta xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" name="generator" content="DocBook XSL-NS Stylesheets V1.74.0">
	<meta xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link rel="home" href="index.html" title="Esper Reference">
	<link rel="up" href="index.html" title="Esper Reference">
	<link rel="prev" href="datetimereference.html" title="Chapter 12. EPL Reference: Date-Time Methods">
	<link rel="next" href="epl-views.html" title="Chapter 14. EPL Reference: Data Windows">
</head>

<body>
	<p xmlns:d="http://docbook.org/ns/docbook" id="title"><a href="./index.html" class="site_href"><strong>www.espertech.com</strong></a><a href="http://www.espertech.com/esper/esper-documentation/" class="doc_href"><strong>Documentation</strong></a></p>
	<ul xmlns:d="http://docbook.org/ns/docbook" class="docnav">
		<li class="previous"><a accesskey="p" href="datetimereference.html"><strong>Prev</strong></a></li>
		<li class="next"><a accesskey="n" href="epl-views.html"><strong>Next</strong></a></li>
	</ul>
	<div class="chapter" lang="en-US">
		<div class="titlepage">
			<div>
				<div>
					<h2 class="title"><a id="aggmethodreference"></a>Chapter 13. EPL Reference: Aggregation Methods</h2>
				</div>
			</div>
		</div>
		<div class="toc">
			<dl>
				<dt><span class="sect1"><a href="aggmethodreference.html#aggmethods-intro">13.1. Overview</a></span></dt>
				<dt><span class="sect1"><a href="aggmethodreference.html#aggmethod-howtouse">13.2. How to Use</a></span></dt>
				<dd>
					<dl>
						<dt><span class="sect2"><a href="aggmethodreference.html#aggmethod-howtouse-synopsis">13.2.1. Syntax</a></span></dt>
						<dt><span class="sect2"><a href="aggmethodreference.html#aggmethod-howtouse-aggregationfunction">13.2.2. Use with Aggregation Function</a></span></dt>
						<dt><span class="sect2"><a href="aggmethodreference.html#aggmethod-howtouse-tablecolumn">13.2.3. Use with Table Column</a></span></dt>
						<dt><span class="sect2"><a href="aggmethodreference.html#aggmethod-chainproperty">13.2.4. Using Dot to Obtain Property Values</a></span></dt>
						<dt><span class="sect2"><a href="aggmethodreference.html#aggmethod-chainenumerate">13.2.5. Using Dot to Enumerate Events</a></span></dt>
					</dl>
				</dd>
				<dt><span class="sect1"><a href="aggmethodreference.html#aggmethod-sorted">13.3. Aggregation Methods for Sorted Aggregations</a></span></dt>
				<dd>
					<dl>
						<dt><span class="sect2"><a href="aggmethodreference.html#aggmethod-sorted-overview">13.3.1. Overview</a></span></dt>
						<dt><span class="sect2"><a href="aggmethodreference.html#aggmethod-multikey">13.3.2. Specifying Composite Keys</a></span></dt>
						<dt><span class="sect2"><a href="aggmethodreference.html#aggmethod-sorted-xevent1param">13.3.3. CeilingEvent, FloorEvent, HigherEvent, LowerEvent, GetEvent</a></span></dt>
						<dt><span class="sect2"><a href="aggmethodreference.html#aggmethod-sorted-xevents1param">13.3.4. CeilingEvents, FloorEvents, HigherEvents, LowerEvents, GetEvents</a></span></dt>
						<dt><span class="sect2"><a href="aggmethodreference.html#aggmethod-sorted-xkey1param">13.3.5. CeilingKey, FloorKey, HigherKey, LowerKey</a></span></dt>
						<dt><span class="sect2"><a href="aggmethodreference.html#aggmethod-sorted-xeventnoparam">13.3.6. FirstEvent, LastEvent, MinBy, MaxBy</a></span></dt>
						<dt><span class="sect2"><a href="aggmethodreference.html#aggmethod-sorted-xeventsnoparam">13.3.7. FirstEvents, LastEvents</a></span></dt>
						<dt><span class="sect2"><a href="aggmethodreference.html#aggmethod-sorted-xkeynoparam">13.3.8. FirstKey, LastKey</a></span></dt>
						<dt><span class="sect2"><a href="aggmethodreference.html#aggmethod-sorted-containskey">13.3.9. ContainsKey</a></span></dt>
						<dt><span class="sect2"><a href="aggmethodreference.html#aggmethod-sorted-countevents">13.3.10. CountEvents</a></span></dt>
						<dt><span class="sect2"><a href="aggmethodreference.html#aggmethod-sorted-countkeys">13.3.11. CountKeys</a></span></dt>
						<dt><span class="sect2"><a href="aggmethodreference.html#aggmethod-sorted-eventsbetween">13.3.12. EventsBetween</a></span></dt>
						<dt><span class="sect2"><a href="aggmethodreference.html#aggmethod-sorted-submap">13.3.13. Submap</a></span></dt>
						<dt><span class="sect2"><a href="aggmethodreference.html#aggmethod-sorted-navigablemapreference">13.3.14. NavigableMapReference</a></span></dt>
					</dl>
				</dd>
				<dt><span class="sect1"><a href="aggmethodreference.html#aggmethod-window">13.4. Aggregation Methods for Window Aggregations</a></span></dt>
				<dd>
					<dl>
						<dt><span class="sect2"><a href="aggmethodreference.html#aggmethod-window-overview">13.4.1. Overview</a></span></dt>
						<dt><span class="sect2"><a href="aggmethodreference.html#aggmethod-window-countevents">13.4.2. CountEvents</a></span></dt>
						<dt><span class="sect2"><a href="aggmethodreference.html#aggmethod-window-listreference">13.4.3. ListReference</a></span></dt>
						<dt><span class="sect2"><a href="aggmethodreference.html#aggmethod-window-firstlast">13.4.4. First, Last</a></span></dt>
					</dl>
				</dd>
				<dt><span class="sect1"><a href="aggmethodreference.html#aggmethod-countminsketch">13.5. Aggregation Methods for CountMinSketch Aggregations</a></span></dt>
				<dt><span class="sect1"><a href="aggmethodreference.html#aggmethod-plugin">13.6. Aggregation Methods for Custom Plug-In Multi-Function Aggregations</a></span></dt>
			</dl>
		</div>
		<div class="sect1" lang="en-US">
			<div class="titlepage">
				<div>
					<div>
						<h2 class="title"><a id="aggmethods-intro"></a>13.1. Overview</h2>
					</div>
				</div>
			</div><a id="d0e35681" class="indexterm"></a>
			<p>
				Aggregation methods are methods that work with aggregations to perform lookups into aggregation state.
			</p>
			<p>
				Aggregation methods are stateless and the use of aggregation methods alone does not cause the runtime to retain any events or other state.
			</p>
			<p>
				There are four types of aggregations that offer aggregation methods:
			</p>
			<div class="itemizedlist">
				<ul>
					<li>
						The <code class="literal">window</code> aggregation, see <a class="xref" href="functionreference.html#epl-function-aggregation-event-window" title="10.2.2.8. Window Aggregation Function">Section 10.2.2.8, “Window Aggregation Function”</a>.
					</li>
					<li>
						The <code class="literal">sorted</code> aggregation, see <a class="xref" href="functionreference.html#epl-function-aggregation-event-sorted" title="10.2.2.7. Sorted Aggregation Function">Section 10.2.2.7, “Sorted Aggregation Function”</a>.
					</li>
					<li>
						The <code class="literal">countminsketch</code> aggregation, see <a class="xref" href="functionreference.html#epl-function-aggregation-approx" title="10.2.3. Approximation Aggregation Functions">Section 10.2.3, “Approximation Aggregation Functions”</a>.
					</li>
					<li>
						Plug-in multi-function aggregations, see <a class="xref" href="extension.html#custom-aggregation-multi" title="22.5.2. Aggregation Multi-Function Development">Section 22.5.2, “Aggregation Multi-Function Development”</a>.
					</li>
				</ul>
			</div>
			<p>
				Aggregation methods are handy when an aggregation organizes events or other data for further lookup. For example, the <code class="literal">sorted</code> aggregation organizes events according to sort criteria
				and offers operations for floor, ceiling, higher and lower keys, and many other operations.
			</p>
			<p>
				Each aggregation makes different aggregation methods available. For example, <code class="literal">sorted</code> provides the <code class="literal">higherKey</code> aggregation method. The <code class="literal">higherKey</code> method is only available for
				use with the <code class="literal">sorted</code> aggregation and not with the <code class="literal">window</code> aggregation.
			</p>
			<p>
				You may use aggregation methods together with aggregation functions without tables, and you may use aggregation methods with table columns that hold aggregations. Further examples are provided below.
			</p>
			<p>
				You may also use aggregation methods with enumeration methods, date-time methods and the dot-syntax to access event properties.
			</p>
		</div>
		<div class="sect1" lang="en-US">
			<div class="titlepage">
				<div>
					<div>
						<h2 class="title"><a id="aggmethod-howtouse"></a>13.2. How to Use</h2>
					</div>
				</div>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="aggmethod-howtouse-synopsis"></a>13.2.1. Syntax</h3>
						</div>
					</div>
				</div>
				<p>
					The syntax for aggregation methods is the same syntax as for any chained invocation:
				</p>
				<pre class="synopsis"><span class="emphasis"><em>input_aggregation</em></span>.<span class="emphasis"><em>aggregation_method_name</em></span>( [<span class="emphasis"><em>method_parameter</em></span> [, <span class="emphasis"><em>method_parameter</em></span> [,...]]])
	  .[ [<span class="emphasis"><em>other_method</em></span>(...) [...]] | <span class="emphasis"><em>property_name</em></span>] </pre>
				<p>
					Following the <span class="emphasis"><em>input_aggregation</em></span> input aggregation (options outlined below), is the <code class="literal">.</code> (dot) operator and the <span class="emphasis"><em>aggregation_method_name</em></span> aggregation method name.
					It follows, in parenthesis, a comma-separated list of method parameter expressions. Additional enumeration or date-time methods can be chained thereafter.
					An event property name can follow for those aggregation or enumeration methods returning an event-typed (non-scalar) element.
				</p>
				<p>
					The examples in this section focus on the <code class="literal">sorted</code> aggregation.
				</p>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="aggmethod-howtouse-aggregationfunction"></a>13.2.2. Use with Aggregation Function</h3>
						</div>
					</div>
				</div>
				<p>
					You may use aggregation methods with the respective aggregation function.
				</p>
				<p>
					The following statement outputs the greatest price strictly less than the current order event price, or null if there is no such value, considering the last 10 minutes of order events.
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select sorted(price).lowerKey(price) as lowerPrice from OrderEvent#time(10 minutes)</pre>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="aggmethod-howtouse-tablecolumn"></a>13.2.3. Use with Table Column</h3>
						</div>
					</div>
				</div>
				<p>
					You may use aggregation methods with table columns.
				</p>
				<p>
					The sample statement below creates a simple un-keyed table that keeps order events sorted by price:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">create table OrderPrices(prices sorted(price) @type('OrderEvent'))</pre>
				<p>
					The next statement aggregates order events into the table column <code class="literal">prices</code> considering the last 10 minutes of order events (the example specifies priority 1 so the runtime always updates the table before other selects):
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">@Priority(1) into table OrderPrices select sorted(*) as prices from OrderEvent#time(10 minutes)</pre>
				<p>
					Now the <code class="literal">prices</code> column of table <code class="literal">OrderPrices</code> is ready. The runtime keeps it continually updated from the last 10 minutes of order events.
				</p>
				<p>
					You may access the table column by providing a table name, column name and the aggregation method. For more information please see <a class="xref" href="nwtable.html#table_keyedaccess" title="6.3.3. Table Column Keyed-Access Expressions">Section 6.3.3, “Table Column Keyed-Access Expressions”</a>.
				</p>
				<p>
					The following statement access the table column to output the first (least) and last (greatest) current price for each order event:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select OrderPrices.prices.firstKey() as leastPrice,
    OrderPrices.prices.lastKey() as greatestPrice 
  from OrderEvent</pre>
				<p>
					You may access the table column by putting the table into the from-clause such as in a subquery or join.
				</p>
				<p>
					The following statement uses a subquery and outputs the least price as well as the order event itself:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select (select prices.firstKey() from OrderPrices) as leastPrice, * from OrderEvent</pre>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="aggmethod-chainproperty"></a>13.2.4. Using Dot to Obtain Property Values</h3>
						</div>
					</div>
				</div>
				<p>
					Use the dot (<code class="literal">.</code>) and the event property name to select an event property of the event, for aggregation methods that return a single event.
				</p>
				<p>
					The example statement below selects the order id of the least price order:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select OrderPrices.prices.firstEvent().orderId as leastPriceOrderId from OrderEvent</pre>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="aggmethod-chainenumerate"></a>13.2.5. Using Dot to Enumerate Events</h3>
						</div>
					</div>
				</div>
				<p>
					Use the dot (<code class="literal">.</code>) and an enumeration method to enumerate events returned by aggregation methods that return one or more events.
				</p>
				<p>
					The example statement below selects the first 3 events among the order events with prices between one and ten:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select OrderPrices.prices.eventsbetween(0, true, 10, true).take(3) as first3Events from OrderEvent</pre>
			</div>
		</div>
		<div class="sect1" lang="en-US">
			<div class="titlepage">
				<div>
					<div>
						<h2 class="title"><a id="aggmethod-sorted"></a>13.3. Aggregation Methods for <code class="literal">Sorted</code> Aggregations</h2>
					</div>
				</div>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="aggmethod-sorted-overview"></a>13.3.1. Overview</h3>
						</div>
					</div>
				</div>
				<p>
					This table lists methods for key-up and key-down:
				</p>
				<div class="table"><a id="aggmethod_sorted_table_keyupdown"></a>
					<p class="title"><b>Table 13.1. <code class="literal">Sorted</code> Aggregation Methods For Key Up/Down</b></p>
					<div class="table-contents">
						<table summary="Sorted Aggregation Methods For Key Up/Down" border="1">
							<colgroup>
								<col>
								<col>
							</colgroup>
							<thead>
								<tr>
									<th>Method</th>
									<th>Result</th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td>ceilingEvent(key)</td>
									<td>
										<p>
											Returns the first event associated with the least key greater than or equal to the given key, or null if there is no such key.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-sorted-xevent1param" title="13.3.3. CeilingEvent, FloorEvent, HigherEvent, LowerEvent, GetEvent">Section 13.3.3, “CeilingEvent, FloorEvent, HigherEvent, LowerEvent, GetEvent”</a>.
										</p>
									</td>
								</tr>
								<tr>
									<td>ceilingEvents(key)</td>
									<td>
										<p>
											Returns all events associated with the least key greater than or equal to the given key, or null if there is no such key.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-sorted-xevents1param" title="13.3.4. CeilingEvents, FloorEvents, HigherEvents, LowerEvents, GetEvents">Section 13.3.4, “CeilingEvents, FloorEvents, HigherEvents, LowerEvents, GetEvents”</a>.
										</p>
									</td>
								</tr>
								<tr>
									<td>ceilingKey(key)</td>
									<td>
										<p>
											Returns the least key greater than or equal to the given key, or null if there is no such key.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-sorted-xkey1param" title="13.3.5. CeilingKey, FloorKey, HigherKey, LowerKey">Section 13.3.5, “CeilingKey, FloorKey, HigherKey, LowerKey”</a>.
										</p>
									</td>
								</tr>
								<tr>
									<td>floorEvent(key)</td>
									<td>
										<p>
											Returns the first event associated with the greatest key less than or equal to the given key, or null if there is no such key.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-sorted-xevent1param" title="13.3.3. CeilingEvent, FloorEvent, HigherEvent, LowerEvent, GetEvent">Section 13.3.3, “CeilingEvent, FloorEvent, HigherEvent, LowerEvent, GetEvent”</a>.
										</p>
									</td>
								</tr>
								<tr>
									<td>floorEvents(key)</td>
									<td>
										<p>
											Returns all events associated with the greatest key less than or equal to the given key, or null if there is no such key.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-sorted-xevents1param" title="13.3.4. CeilingEvents, FloorEvents, HigherEvents, LowerEvents, GetEvents">Section 13.3.4, “CeilingEvents, FloorEvents, HigherEvents, LowerEvents, GetEvents”</a>.
										</p>
									</td>
								</tr>
								<tr>
									<td>floorKey(key)</td>
									<td>
										<p>
											Returns the greatest key less than or equal to the given key, or null if there is no such key.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-sorted-xkey1param" title="13.3.5. CeilingKey, FloorKey, HigherKey, LowerKey">Section 13.3.5, “CeilingKey, FloorKey, HigherKey, LowerKey”</a>.
										</p>
									</td>
								</tr>
								<tr>
									<td>higherEvent(key)</td>
									<td>
										<p>
											Returns the first event associated with the least key strictly greater than the given key, or null if there is no such key.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-sorted-xevent1param" title="13.3.3. CeilingEvent, FloorEvent, HigherEvent, LowerEvent, GetEvent">Section 13.3.3, “CeilingEvent, FloorEvent, HigherEvent, LowerEvent, GetEvent”</a>.
										</p>
									</td>
								</tr>
								<tr>
									<td>higherEvents(key)</td>
									<td>
										<p>
											Returns all events associated with the least key strictly greater than the given key, or null if there is no such key.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-sorted-xevents1param" title="13.3.4. CeilingEvents, FloorEvents, HigherEvents, LowerEvents, GetEvents">Section 13.3.4, “CeilingEvents, FloorEvents, HigherEvents, LowerEvents, GetEvents”</a>.
										</p>
									</td>
								</tr>
								<tr>
									<td>higherKey(key)</td>
									<td>
										<p>
											Returns the least key strictly greater than the given key, or null if there is no such key.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-sorted-xkey1param" title="13.3.5. CeilingKey, FloorKey, HigherKey, LowerKey">Section 13.3.5, “CeilingKey, FloorKey, HigherKey, LowerKey”</a>.
										</p>
									</td>
								</tr>
								<tr>
									<td>lowerEvent(key)</td>
									<td>
										<p>
											Returns the first event associated with the greatest key strictly less than the given key, or null if there is no such key.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-sorted-xevent1param" title="13.3.3. CeilingEvent, FloorEvent, HigherEvent, LowerEvent, GetEvent">Section 13.3.3, “CeilingEvent, FloorEvent, HigherEvent, LowerEvent, GetEvent”</a>.
										</p>
									</td>
								</tr>
								<tr>
									<td>lowerEvents(key)</td>
									<td>
										<p>
											Returns all events associated with the greatest key strictly less than the given key, or null if there is no such key.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-sorted-xevents1param" title="13.3.4. CeilingEvents, FloorEvents, HigherEvents, LowerEvents, GetEvents">Section 13.3.4, “CeilingEvents, FloorEvents, HigherEvents, LowerEvents, GetEvents”</a>.
										</p>
									</td>
								</tr>
								<tr>
									<td>lowerKey(key)</td>
									<td>
										<p>
											Returns the greatest key strictly less than the given key, or null if there is no such key.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-sorted-xkey1param" title="13.3.5. CeilingKey, FloorKey, HigherKey, LowerKey">Section 13.3.5, “CeilingKey, FloorKey, HigherKey, LowerKey”</a>.
										</p>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div><br class="table-break">
				<p>
					This table lists methods for least and greatest:
				</p>
				<div class="table"><a id="aggmethod_sorted_table_keyfirstlast"></a>
					<p class="title"><b>Table 13.2. <code class="literal">Sorted</code> Aggregation Methods For Key First/Last</b></p>
					<div class="table-contents">
						<table summary="Sorted Aggregation Methods For Key First/Last" border="1">
							<colgroup>
								<col>
								<col>
							</colgroup>
							<thead>
								<tr>
									<th>Method</th>
									<th>Result</th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td>firstEvent() or minBy()</td>
									<td>
										<p>
											Returns the first event associated with the least key, or null if empty.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-sorted-xeventnoparam" title="13.3.6. FirstEvent, LastEvent, MinBy, MaxBy">Section 13.3.6, “FirstEvent, LastEvent, MinBy, MaxBy”</a>.
										</p>
									</td>
								</tr>
								<tr>
									<td>firstEvents()</td>
									<td>
										<p>
											Returns all events associated with the least key, or null if empty.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-sorted-xeventsnoparam" title="13.3.7. FirstEvents, LastEvents">Section 13.3.7, “FirstEvents, LastEvents”</a>.
										</p>
									</td>
								</tr>
								<tr>
									<td>firstKey()</td>
									<td>
										<p>
											Returns the first (least) key.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-sorted-xkeynoparam" title="13.3.8. FirstKey, LastKey">Section 13.3.8, “FirstKey, LastKey”</a>.
										</p>
									</td>
								</tr>
								<tr>
									<td>lastEvent() or maxBy()</td>
									<td>
										<p>
											Returns the first event associated with the greatest key, or null if empty.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-sorted-xeventnoparam" title="13.3.6. FirstEvent, LastEvent, MinBy, MaxBy">Section 13.3.6, “FirstEvent, LastEvent, MinBy, MaxBy”</a>.
										</p>
									</td>
								</tr>
								<tr>
									<td>lastEvents()</td>
									<td>
										<p>
											Returns all events associated with the greatest key, or null if empty.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-sorted-xeventsnoparam" title="13.3.7. FirstEvents, LastEvents">Section 13.3.7, “FirstEvents, LastEvents”</a>.
										</p>
									</td>
								</tr>
								<tr>
									<td>lastKey()</td>
									<td>
										<p>
											Returns the last (greatest) key.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-sorted-xkeynoparam" title="13.3.8. FirstKey, LastKey">Section 13.3.8, “FirstKey, LastKey”</a>.
										</p>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div><br class="table-break">
				<p>
					This table lists methods for getting for specific keys, checking contains and getting counts:
				</p>
				<div class="table"><a id="aggmethod_sorted_table_getcontaincount"></a>
					<p class="title"><b>Table 13.3. <code class="literal">Sorted</code> Aggregation Methods For Get, Contains, Count</b></p>
					<div class="table-contents">
						<table summary="Sorted Aggregation Methods For Get, Contains, Count" border="1">
							<colgroup>
								<col>
								<col>
							</colgroup>
							<thead>
								<tr>
									<th>Method</th>
									<th>Result</th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td>containsKey(key)</td>
									<td>
										<p>
											Returns true if the aggregation contains the specified key.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-sorted-containskey" title="13.3.9. ContainsKey">Section 13.3.9, “ContainsKey”</a>.
										</p>
									</td>
								</tr>
								<tr>
									<td>countEvents()</td>
									<td>
										<p>
											Returns the number of events in the aggregation.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-sorted-countevents" title="13.3.10. CountEvents">Section 13.3.10, “CountEvents”</a>.
										</p>
									</td>
								</tr>
								<tr>
									<td>countKeys()</td>
									<td>
										<p>
											Returns the number of keys in the aggregation.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-sorted-countkeys" title="13.3.11. CountKeys">Section 13.3.11, “CountKeys”</a>.
										</p>
									</td>
								</tr>
								<tr>
									<td>getEvent(key)</td>
									<td>
										<p>
											Returns the first event for the specified key, or null if there is no such key.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-sorted-xevent1param" title="13.3.3. CeilingEvent, FloorEvent, HigherEvent, LowerEvent, GetEvent">Section 13.3.3, “CeilingEvent, FloorEvent, HigherEvent, LowerEvent, GetEvent”</a>.
										</p>
									</td>
								</tr>
								<tr>
									<td>getEvents(key)</td>
									<td>
										<p>
											Returns all events for the specified key, or null if there is no such key.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-sorted-xevents1param" title="13.3.4. CeilingEvents, FloorEvents, HigherEvents, LowerEvents, GetEvents">Section 13.3.4, “CeilingEvents, FloorEvents, HigherEvents, LowerEvents, GetEvents”</a>.
										</p>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div><br class="table-break">
				<p>
					This table lists methods for sub-map, between-values and reference:
				</p>
				<div class="table"><a id="aggmethod_sorted_table_submap"></a>
					<p class="title"><b>Table 13.4. <code class="literal">Sorted</code> Aggregation Methods For Submap, Between and Reference</b></p>
					<div class="table-contents">
						<table summary="Sorted Aggregation Methods For Submap, Between and Reference" border="1">
							<colgroup>
								<col>
								<col>
							</colgroup>
							<thead>
								<tr>
									<th>Method</th>
									<th>Result</th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td>eventsBetween(fromKey, fromInclusive, toKey, toInclusive)</td>
									<td>
										<p>
											Returns all events of a portion of this aggregation whose keys range from <code class="literal">fromKey</code> to <code class="literal">toKey</code>.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-sorted-eventsbetween" title="13.3.12. EventsBetween">Section 13.3.12, “EventsBetween”</a>.
										</p>
									</td>
								</tr>
								<tr>
									<td>submap(fromKey, fromInclusive, toKey, toInclusive)</td>
									<td>
										<p>
											Returns a submap of type <code class="literal">NavigableMap&lt;Object, Object[]&gt;</code> that is a navigable map containing keys and events of the portion of the aggregation whose keys range from <code class="literal">fromKey</code> to <code class="literal">toKey</code>.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-sorted-submap" title="13.3.13. Submap">Section 13.3.13, “Submap”</a>.
										</p>
									</td>
								</tr>
								<tr>
									<td>navigableMapReference()</td>
									<td>
										<p>
											NOTE: This method returns an object that the runtime may concurrently modify and that is only valid for the period of evaluation of the current event or time.
										</p>
										<p>
											Returns a <code class="literal">NavigableMap&lt;Object, Collection&lt;EventBean&gt;&gt;</code> that is an unmodifiable view of keys and <code class="literal">EventBean</code> instances.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-sorted-navigablemapreference" title="13.3.14. NavigableMapReference">Section 13.3.14, “NavigableMapReference”</a>.
										</p>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div><br class="table-break">
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="aggmethod-multikey"></a>13.3.2. Specifying Composite Keys</h3>
						</div>
					</div>
				</div>
				<p>
					Use <code class="literal">com.espertech.esper.common.client.util.HashableMultiKey</code> when the <code class="literal">sorted</code> aggregation has multiple keys.
					E.g. for <code class="literal">sorted(string, double)</code> use <code class="literal">new HashableMultiKey(orderId, price)</code>.
				</p>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="aggmethod-sorted-xevent1param"></a>13.3.3. <code class="literal">CeilingEvent</code>, <code class="literal">FloorEvent</code>, <code class="literal">HigherEvent</code>, <code class="literal">LowerEvent</code>, <code class="literal">GetEvent</code></h3>
						</div>
					</div>
				</div>
				<p>
					The methods accept a single key parameter and return the event or null if an event was not found. If the result is multiple events, the method returns the oldest ceiling/floor/lower/higher/keyed event.
				</p>
				<div class="table"><a id="aggmethod_sorted_table_xevent1param"></a>
					<p class="title"><b>Table 13.5. <code class="literal">Sorted</code> Aggregation Methods - Keyed Returning Single Event</b></p>
					<div class="table-contents">
						<table summary="Sorted Aggregation Methods - Keyed Returning Single Event" border="1">
							<colgroup>
								<col>
								<col>
							</colgroup>
							<thead>
								<tr>
									<th>Method</th>
									<th>Result</th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td>ceilingEvent(key)</td>
									<td>
										<p>
											Returns the first event associated with the least key greater than or equal to the given key, or null if there is no such key.
										</p>
									</td>
								</tr>
								<tr>
									<td>floorEvent(key)</td>
									<td>
										<p>
											Returns the first event associated with the greatest key less than or equal to the given key, or null if there is no such key.
										</p>
									</td>
								</tr>
								<tr>
									<td>higherEvent(key)</td>
									<td>
										<p>
											Returns the first event associated with the least key strictly greater than the given key, or null if there is no such key.
										</p>
									</td>
								</tr>
								<tr>
									<td>lowerEvent(key)</td>
									<td>
										<p>
											Returns the first event associated with the greatest key strictly less than the given key, or null if there is no such key.
										</p>
									</td>
								</tr>
								<tr>
									<td>getEvent(key)</td>
									<td>
										<p>
											Returns the first event for the specified key, or null if there is no such key.
										</p>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div><br class="table-break">
				<p>
					Assuming the <code class="literal">OrderPrices</code> table exists as defined above, this example statement, when an order event arrives, returns the order event associated with the greatest price strictly less than the given price, or null if there is no such price:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select OrderPrices.prices.lowerEvent(price) as lowerPriceEvent from OrderEvent</pre>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="aggmethod-sorted-xevents1param"></a>13.3.4. <code class="literal">CeilingEvents</code>, <code class="literal">FloorEvents</code>, <code class="literal">HigherEvents</code>, <code class="literal">LowerEvents</code>, <code class="literal">GetEvents</code></h3>
						</div>
					</div>
				</div>
				<p>
					The methods accepts a single key parameter and return all events or null if no events are found.
				</p>
				<div class="table"><a id="aggmethod_sorted_table_xevents1param"></a>
					<p class="title"><b>Table 13.6. <code class="literal">Sorted</code> Aggregation Methods - Keyed Returning Multiple Events</b></p>
					<div class="table-contents">
						<table summary="Sorted Aggregation Methods - Keyed Returning Multiple Events" border="1">
							<colgroup>
								<col>
								<col>
							</colgroup>
							<thead>
								<tr>
									<th>Method</th>
									<th>Result</th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td>ceilingEvents(key)</td>
									<td>
										<p>
											Returns all events associated with the least key greater than or equal to the given key, or null if there is no such key.
										</p>
									</td>
								</tr>
								<tr>
									<td>floorEvents(key)</td>
									<td>
										<p>
											Returns all events associated with the greatest key less than or equal to the given key, or null if there is no such key.
										</p>
									</td>
								</tr>
								<tr>
									<td>higherEvents(key)</td>
									<td>
										<p>
											Returns all events associated with the least key strictly greater than the given key, or null if there is no such key.
										</p>
									</td>
								</tr>
								<tr>
									<td>lowerEvents(key)</td>
									<td>
										<p>
											Returns all events associated with the greatest key strictly less than the given key, or null if there is no such key.
										</p>
									</td>
								</tr>
								<tr>
									<td>getEvents(key)</td>
									<td>
										<p>
											Returns all events for the specified key, or null if there is no such key.
										</p>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div><br class="table-break">
				<p>
					Assuming the <code class="literal">OrderPrices</code> table exists as defined above, this example statement, when an order event arrives, returns all order events associated with the greatest price strictly less than the given price, or null if there is no such price:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select OrderPrices.prices.lowerEvents(price) as lowerPriceEvents from OrderEvent</pre>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="aggmethod-sorted-xkey1param"></a>13.3.5. <code class="literal">CeilingKey</code>, <code class="literal">FloorKey</code>, <code class="literal">HigherKey</code>, <code class="literal">LowerKey</code></h3>
						</div>
					</div>
				</div>
				<p>
					The methods accepts a single key parameter and return the key or null if no key is found.
				</p>
				<div class="table"><a id="aggmethod_sorted_table_xkey1param"></a>
					<p class="title"><b>Table 13.7. <code class="literal">Sorted</code> Aggregation Methods - Keyed Returning Key</b></p>
					<div class="table-contents">
						<table summary="Sorted Aggregation Methods - Keyed Returning Key" border="1">
							<colgroup>
								<col>
								<col>
							</colgroup>
							<thead>
								<tr>
									<th>Method</th>
									<th>Result</th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td>ceilingKey(key)</td>
									<td>
										<p>
											Returns the least key greater than or equal to the given key, or null if there is no such key.
										</p>
									</td>
								</tr>
								<tr>
									<td>floorKey(key)</td>
									<td>
										<p>
											Returns the greatest key less than or equal to the given key, or null if there is no such key.
										</p>
									</td>
								</tr>
								<tr>
									<td>higherKey(key)</td>
									<td>
										<p>
											Returns the least key strictly greater than the given key, or null if there is no such key.
										</p>
									</td>
								</tr>
								<tr>
									<td>lowerKey(key)</td>
									<td>
										<p>
											Returns the greatest key strictly less than the given key, or null if there is no such key.
										</p>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div><br class="table-break">
				<p>
					Assuming the <code class="literal">OrderPrices</code> table exists as defined above, this example statement, when an order event arrives, returns the greatest price strictly less than the given price, or null if there is no such price:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select OrderPrices.prices.lowerKey(price) as lowerPrice from OrderEvent</pre>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="aggmethod-sorted-xeventnoparam"></a>13.3.6. <code class="literal">FirstEvent</code>, <code class="literal">LastEvent</code>, <code class="literal">MinBy</code>, <code class="literal">MaxBy</code></h3>
						</div>
					</div>
				</div>
				<p>
					The methods have no parameter and return the first (least) or last (greatest) event or null if an event was not found. If the result is multiple events, the method returns the oldest first/last (least/greatest) event.
				</p>
				<div class="table"><a id="aggmethod_sorted_table_xeventnoparam"></a>
					<p class="title"><b>Table 13.8. <code class="literal">Sorted</code> Aggregation Methods - Unparameterized Returning Single Event</b></p>
					<div class="table-contents">
						<table summary="Sorted Aggregation Methods - Unparameterized Returning Single Event" border="1">
							<colgroup>
								<col>
								<col>
							</colgroup>
							<thead>
								<tr>
									<th>Method</th>
									<th>Result</th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td>firstEvent() or minBy()</td>
									<td>
										<p>
											Returns the first event associated with the least key, or null if empty.
										</p>
									</td>
								</tr>
								<tr>
									<td>lastEvent() or maxBy()</td>
									<td>
										<p>
											Returns the first event associated with the greatest key, or null if empty.
										</p>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div><br class="table-break">
				<p>
					Assuming the <code class="literal">OrderPrices</code> table exists as defined above, this example statement, when an order event arrives, returns the order event associated with the least price , or null if there is no such price:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select OrderPrices.prices.firstEvent() as leastPriceEvent from OrderEvent</pre>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="aggmethod-sorted-xeventsnoparam"></a>13.3.7. <code class="literal">FirstEvents</code>, <code class="literal">LastEvents</code></h3>
						</div>
					</div>
				</div>
				<p>
					The methods have no parameter and return the first (least) or last (greatest) events or null if no events are found.
				</p>
				<div class="table"><a id="aggmethod_sorted_table_xeventsnoparam"></a>
					<p class="title"><b>Table 13.9. <code class="literal">Sorted</code> Aggregation Methods - Unparameterized Returning Multiple Events</b></p>
					<div class="table-contents">
						<table summary="Sorted Aggregation Methods - Unparameterized Returning Multiple Events" border="1">
							<colgroup>
								<col>
								<col>
							</colgroup>
							<thead>
								<tr>
									<th>Method</th>
									<th>Result</th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td>firstEvents()</td>
									<td>
										<p>
											Returns all events associated with the least key, or null if empty.
										</p>
									</td>
								</tr>
								<tr>
									<td>lastEvents()</td>
									<td>
										<p>
											Returns all events associated with the greatest key, or null if empty.
										</p>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div><br class="table-break">
				<p>
					Assuming the <code class="literal">OrderPrices</code> table exists as defined above, this example statement, when an order event arrives, returns all order events associated with the least price or null if there is no such price:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select OrderPrices.prices.firstEvents(price) as lowerPriceEvents from OrderEvent</pre>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="aggmethod-sorted-xkeynoparam"></a>13.3.8. <code class="literal">FirstKey</code>, <code class="literal">LastKey</code></h3>
						</div>
					</div>
				</div>
				<p>
					The methods have no parameter and return the the first (least) or last (greatest) key or null if no key is found.
				</p>
				<div class="table"><a id="aggmethod_sorted_table_xkeynoparam"></a>
					<p class="title"><b>Table 13.10. <code class="literal">Sorted</code> Aggregation Methods - Unparameterized Returning Key</b></p>
					<div class="table-contents">
						<table summary="Sorted Aggregation Methods - Unparameterized Returning Key" border="1">
							<colgroup>
								<col>
								<col>
							</colgroup>
							<thead>
								<tr>
									<th>Method</th>
									<th>Result</th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td>firstKey()</td>
									<td>
										<p>
											Returns the first (least) key.
										</p>
									</td>
								</tr>
								<tr>
									<td>lastKey()</td>
									<td>
										<p>
											Returns the last (greatest) key.
										</p>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div><br class="table-break">
				<p>
					Assuming the <code class="literal">OrderPrices</code> table exists as defined above, this example statement, when an order event arrives, returns the least price or null if there is no such price:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select OrderPrices.prices.firstKey() as leastPrice from OrderEvent</pre>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="aggmethod-sorted-containskey"></a>13.3.9. <code class="literal">ContainsKey</code></h3>
						</div>
					</div>
				</div>
				<p>
					This method accepts a single key parameter and returns a <code class="literal">boolean</code>-type value indicating whether the key is found, or null if using tables and the table row is not found.
				</p>
				<p>
					Assuming the <code class="literal">OrderPrices</code> table exists as defined above, this example statement, when an order event arrives, returns <code class="literal">true</code> if a price of zero exists:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select OrderPrices.prices.containsKey(0) as priceZeroFound from OrderEvent</pre>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="aggmethod-sorted-countevents"></a>13.3.10. <code class="literal">CountEvents</code></h3>
						</div>
					</div>
				</div>
				<p>
					This method has no parameters and returns an <code class="literal">int</code>-type count of the number of events, or null if using tables and the table row is not found.
				</p>
				<p>
					Assuming the <code class="literal">OrderPrices</code> table exists as defined above, this example statement, when an order event arrives, returns the number of events:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select OrderPrices.prices.countEvents() as numEvents from OrderEvent</pre>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="aggmethod-sorted-countkeys"></a>13.3.11. <code class="literal">CountKeys</code></h3>
						</div>
					</div>
				</div>
				<p>
					This method has no parameters and returns an <code class="literal">int</code>-type count of the number of keys, or null if using tables and the table row is not found.
				</p>
				<p>
					Assuming the <code class="literal">OrderPrices</code> table exists as defined above, this example statement, when an order event arrives, returns the number of prices:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select OrderPrices.prices.countKeys() as numPrices from OrderEvent</pre>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="aggmethod-sorted-eventsbetween"></a>13.3.12. <code class="literal">EventsBetween</code></h3>
						</div>
					</div>
				</div>
				<p>
					This method accepts four parameters, namely the from-key, the <code class="literal">boolean</code>-typed from-inclusive indicator, the to-key and the <code class="literal">boolean</code>-typed to-inclusive indicator.
					The method returns all events whose keys range from from-key to to-key.
					If from-key and to-key are equal, the returned value is empty unless from-inclusive and to-inclusive are both true.
					The from-key must be less or equal to to-key.
				</p>
				<p>
					Assuming the <code class="literal">OrderPrices</code> table exists as defined above, this example statement, when an order event arrives, returns all events with prices between one (inclusive) and ten (inclusive):
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select OrderPrices.prices.eventsBetween(1, true, 10, true) as eventsPricedOneToTen from OrderEvent</pre>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="aggmethod-sorted-submap"></a>13.3.13. <code class="literal">Submap</code></h3>
						</div>
					</div>
				</div>
				<p>
					This method accepts four parameters, namely the from-key, the <code class="literal">boolean</code>-typed from-inclusive indicator, the to-key and the <code class="literal">boolean</code>-typed to-inclusive indicator.
					The method returns an object of type <code class="literal">NavigableMap&lt;Object, Object[]&gt;</code> that is a shallow copy of all keys of a portion of this aggregation whose keys range from <code class="literal">fromKey</code> to <code class="literal">toKey</code>.
					If from-key and to-key are equal, the returned value is empty unless from-inclusive and to-inclusive are both true.
					The from-key must be less or equal to to-key.
				</p>
				<p>
					Assuming the <code class="literal">OrderPrices</code> table exists as defined above, this example statement, when an order event arrives, returns all keys and events as a navigable map with prices between one (inclusive) and ten (inclusive):
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select OrderPrices.prices.submap(1, true, 10, true) as keysAndEventsPricedOneToTen from OrderEvent</pre>
				<p>
					The map keys are the key objects. Each map value is an array containing the event underlying object of the events for the key.
				</p>
				<p>
					Modifications on the map returned by the method are not reflected back into the aggregation state. The map returned by the method is in effect a shallow copy.
				</p>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="aggmethod-sorted-navigablemapreference"></a>13.3.14. <code class="literal">NavigableMapReference</code></h3>
						</div>
					</div>
				</div>
				<p>
					This method has no parameters and returns an object of type <code class="literal">NavigableMap&lt;Object, Collection&lt;EventBean&gt;&gt;</code> that is an unmodifiable view of keys and unmodifiable collections of <code class="literal">EventBean</code> instances.
				</p>
				<div xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="warning">
					<h2>Warning</h2>
					<div class="itemizedlist">
						<ul>
							<li>
								<p>
									This method returns an object that the runtime may concurrently modify and that is only valid for the period of evaluation of the current event or time.
								</p>
							</li>
						</ul>
					</div>
				</div>
				<p>
					Assuming the <code class="literal">OrderPrices</code> table exists as defined above, this example statement, when an order event arrives, returns all keys and events as a navigable map:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select OrderPrices.prices.navigableMapReference() as prices from OrderEvent</pre>
				<p>
					The map keys are the key objects. Each map value is an a collection of <code class="literal">EventBean</code> events for the key.
				</p>
				<p>
					Modifications on the map returned by the method are not allowed. The map returned by the method is in effect a wrapper of the actual aggregation state.
				</p>
			</div>
		</div>
		<div class="sect1" lang="en-US">
			<div class="titlepage">
				<div>
					<div>
						<h2 class="title"><a id="aggmethod-window"></a>13.4. Aggregation Methods for <code class="literal">Window</code> Aggregations</h2>
					</div>
				</div>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="aggmethod-window-overview"></a>13.4.1. Overview</h3>
						</div>
					</div>
				</div>
				<p>
					The below table summarizes the built-in aggregation methods for use with the <code class="literal">window</code> aggregation:
				</p>
				<div class="table"><a id="aggmethod_window_table"></a>
					<p class="title"><b>Table 13.11. <code class="literal">Window</code> Aggregation Methods</b></p>
					<div class="table-contents">
						<table summary="Window Aggregation Methods" border="1">
							<colgroup>
								<col>
								<col>
							</colgroup>
							<thead>
								<tr>
									<th>Method</th>
									<th>Result</th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td>listReference()</td>
									<td>
										<p>
											NOTE: This method returns an object that the runtime may concurrently modify and that is only valid for the period of evaluation of the current event or time.
										</p>
										<p>
											Returns a <code class="literal">List&lt;EventBean&gt;</code> that is an unmodifiable view of <code class="literal">EventBean</code> instances.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-window-listreference" title="13.4.3. ListReference">Section 13.4.3, “ListReference”</a>.
										</p>
									</td>
								</tr>
								<tr>
									<td>countEvents()</td>
									<td>
										<p>
											Returns the number of events.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-window-countevents" title="13.4.2. CountEvents">Section 13.4.2, “CountEvents”</a>.
										</p>
									</td>
								</tr>
								<tr>
									<td>first()</td>
									<td>
										<p>
											Returns the oldest event or null if the aggregation is empty.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-window-firstlast" title="13.4.4. First, Last">Section 13.4.4, “First, Last”</a>.
										</p>
									</td>
								</tr>
								<tr>
									<td>last()</td>
									<td>
										<p>
											Returns the newest event or null if the aggregation is empty.
										</p>
										<p>
											<a class="xref" href="aggmethodreference.html#aggmethod-window-firstlast" title="13.4.4. First, Last">Section 13.4.4, “First, Last”</a>.
										</p>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div><br class="table-break">
				<p>
					The sample statement below creates a simple un-keyed table that keeps order events:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">create table OrdersTable(orders window(*) @type('OrderEvent'))</pre>
				<p>
					The next statement aggregates order events into the table column <code class="literal">orders</code> considering the last 10 minutes of order events (the example specifies priority 1 so the runtime always updates the table before other selects):
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">@Priority(1) into table OrdersTable select window(*) as orders from OrderEvent#time(10 minutes)</pre>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="aggmethod-window-countevents"></a>13.4.2. <code class="literal">CountEvents</code></h3>
						</div>
					</div>
				</div>
				<p>
					This method has no parameters and returns an <code class="literal">int</code>-type count of the number of events, or null if using tables and the table row is not found.
				</p>
				<p>
					Assuming the <code class="literal">OrdersTable</code> table exists as defined above, this example statement, when an order event arrives, returns the number of events:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select OrdersTable.orders.countEvents() as numEvents from OrderEvent</pre>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="aggmethod-window-listreference"></a>13.4.3. <code class="literal">ListReference</code></h3>
						</div>
					</div>
				</div>
				<p>
					This method has no parameters and returns an object of type <code class="literal">List&lt;EventBean&gt;</code> that is an unmodifiable list of <code class="literal">EventBean</code> instances.
				</p>
				<div xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="warning">
					<h2>Warning</h2>
					<div class="itemizedlist">
						<ul>
							<li>
								<p>
									This method returns an object that the runtime may concurrently modify and that is only valid for the period of evaluation of the current event or time.
								</p>
							</li>
						</ul>
					</div>
				</div>
				<p>
					Assuming the <code class="literal">OrdersTable</code> table exists as defined above, this example statement, when an order event arrives, returns all events as a list:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select OrderPrices.orders.listReference() as prices from OrderEvent</pre>
				<p>
					Modifications on the list returned by the method are not allowed. The list returned by the method is in effect a wrapper of the actual aggregation state.
				</p>
			</div>
			<div class="sect2" lang="en-US">
				<div class="titlepage">
					<div>
						<div>
							<h3 class="title"><a id="aggmethod-window-firstlast"></a>13.4.4. <code class="literal">First</code>, <code class="literal">Last</code></h3>
						</div>
					</div>
				</div>
				<p>
					The method has no parameter and return the first (oldest) or last (newest) event or null if an event was not found.
				</p>
				<p>
					Assuming the <code class="literal">OrdersTable</code> table exists as defined above, this example statement, when an order event arrives, returns the oldest order event, or null if there is no such event:
				</p>
				<pre xmlns="" xmlns:d="http://docbook.org/ns/docbook" xmlns:rf="java:org.jboss.highlight.XhtmlRendererFactory" class="">select OrdersTable.orders.first() as oldestOrder from OrderEvent</pre>
				<p>
					You may optionally specify an event property name as a parameter, in which case the method returns the event property value of the oldest/newest event or null if there is no such event.
				</p>
			</div>
		</div>
		<div class="sect1" lang="en-US">
			<div class="titlepage">
				<div>
					<div>
						<h2 class="title"><a id="aggmethod-countminsketch"></a>13.5. Aggregation Methods for <code class="literal">CountMinSketch</code> Aggregations</h2>
					</div>
				</div>
			</div>
			<p>
				The aggregation methods for count-min sketch are <code class="literal">countMinSketchFrequency</code> and <code class="literal">countMinSketchTopk</code> and are already described in <a class="xref" href="functionreference.html#epl-function-aggregation-approx" title="10.2.3. Approximation Aggregation Functions">Section 10.2.3, “Approximation Aggregation Functions”</a>.
			</p>
		</div>
		<div class="sect1" lang="en-US">
			<div class="titlepage">
				<div>
					<div>
						<h2 class="title"><a id="aggmethod-plugin"></a>13.6. Aggregation Methods for Custom Plug-In Multi-Function Aggregations</h2>
					</div>
				</div>
			</div>
			<p>
				The extension code defines the aggregation methods and their parameters. For more information please see <a class="xref" href="extension.html#custom-aggregation-multi" title="22.5.2. Aggregation Multi-Function Development">Section 22.5.2, “Aggregation Multi-Function Development”</a>.
			</p>
		</div>
	</div>
	<ul xmlns:d="http://docbook.org/ns/docbook" class="docnav">
		<li class="previous"><a accesskey="p" href="datetimereference.html"><strong>Prev</strong>Chapter 12. EPL Reference: Date-Time Methods</a></li>
		<li class="up"><a accesskey="u" href="#"><strong>Top of page</strong></a></li>
		<li class="home"><a accesskey="h" href="index.html"><strong>Front page</strong></a></li>
		<li class="next"><a accesskey="n" href="epl-views.html"><strong>Next</strong>Chapter 14. EPL Reference: Data Windows</a></li>
	</ul>
</body>

</html>